<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------
namespace Think;

class ListOrder
{
    public $order; // 排序字段
    public $method; // 排序方式 desc asc
    public $content;// id asc,name desc....

    /**
     * 架构函数
     */
    public function __construct($request, $default = false)
    {
        if ($request) {
            if($request['method']){
                $this->method = $request['method'] == 'asc' ? 'desc' : 'asc';
            }else{
                $this->method ='';
            }
            $this->order = $request['order'];
            $this->content = $this->order . ' ' . $this->method;
            if($this->content==' '){
                $this->content = $default;
            }else {
                if ($default) {
                    $this->content .= (',' . $default);
                }
            }
        } else {
            $this->content = $default;
        }
        if (empty($this->content)) {
            $this->content = ' 1 desc';
        }
    }

}
